<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Home\Model;
use Think\Model;
class MoodreplyModel extends Model{
    public function addMoodreply($data){
        if(!empty($data)){
            $data['create_time']= date('Y-m-d H:i:s');
            $data['prent_id']=0;
            $MoodInfo=$this->add($data);
            if($MoodInfo!==false){
                /* @var
                 *  $List 返回新增的那条数据 
                 * 
                 * type */
                $where['m.id']=$MoodInfo;
                $join="__PERSONAL__ p on p.uid=m.uid";
                $field="m.*,p.nickname,p.user_tx";
                $a=$this->alias('m')
                        ->where($where)
                        ->join($join)
                        ->field($field)
                        ->find();
                if($a){
                    return $a;
                }else{
                    return false;
                }
            }
        }else{
            return false;
        }
    }
    
    //查看关于动态的回复
        /*
         * $mid  上级动态的ID 
         */
        public function hasreply($mid){
            $where['m.mid']=$mid;
            $join="left join __PERSONAL__ p ON m.uid=p.uid ";
            $field="m.*,p.nickname,p.user_tx";
            $moodList= $this->alias('m')
                            ->where($where)
                            ->field($field)
                            ->join($join)
                            ->select();
            if($moodList){
                return $moodList;
            }else{
                return false;
            }
        }                   
}